Skip to content

Allow both hackney 1.x and 4.x - #170

Merged
lau merged 1 commit into
lau:masterfrom
legoscia:hackney-1.x-4.x
Jul 14, 2026
Merged

Allow both hackney 1.x and 4.x#170
lau merged 1 commit into
lau:masterfrom
legoscia:hackney-1.x-4.x

Conversation

@legoscia

Copy link
Copy Markdown
Contributor

Let's allow both old and new hackney versions in order to make the transition easier for downstream projects.

Closes #155.


This is an alternative to #168.

Let's allow both old and new hackney versions in order to make the
transition easier for downstream projects.

Closes lau#155.
@xu-chris

Copy link
Copy Markdown

@lau this is a good fix. Any thoughts?

@heywhy

heywhy commented Jun 27, 2026

Copy link
Copy Markdown

@lau hi, i hope you're doing great. this pr contains important changes to mitigate the vulnerability with hackney, i hope you can speed up the resolution process.

@gilbertwong96

Copy link
Copy Markdown

Hi, @lau Any chance to merge it and bump a new version for tzdata ?

# Hackney 4.x returns the body as a binary in the result from :hackney.get
{:ok, result}
end
defp get_body(client_ref) do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best to drop support for Hackney 1.x considering hackney 1.x is vulnerable and this major version won't be maintained anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Longer term, absolutely. My goal with this change is to make it easier for a project with a complex dependency tree to move towards Hackney 4.x. If one dependency depends on Hackney 1.x and another depends on 4.x, the upgrade is blocked, but if tzdata allows both versions, then progress towards Hackney 4.x can be made step by step.

end
defp get_body(client_ref) do
# Hackney 1.x returns a client_ref that we can fetch the body from
:hackney.body(client_ref)

@stepchud stepchud Jul 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a deprecation warning here?

@Kariiem

Kariiem commented Jul 1, 2026

Copy link
Copy Markdown

can hackney be also declared as a optional dep? since the client itself checks if it's loaded or not, and there is Tzdata.Http.Client behaviour.

@legoscia

legoscia commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

can hackney be also declared as a optional dep? since the client itself checks if it's loaded or not, and there is Tzdata.Http.Client behaviour.

That is a good point. I think it makes sense to declare it as optional. I wasn't sure whether to include it in this pull request or as a separate change, but maybe that's worth doing.

@lwld

lwld commented Jul 3, 2026

Copy link
Copy Markdown

+1
@lau this would be REALLY good to do soon as it blocks updating hackney versions with vulnerabilities

“A bunch of vulnerabilities I reported in hackney were just disclosed. Please upgrade to 4.0.1 ASAP. I know this is gonna start dependency hell so please take some time for this. Please repost for reach. #ElixirLang”

https://www.linkedin.com/feed/update/urn:li:activity:7464785377061605376/?utm_source=share&utm_medium=member_desktop&rcm=ACoAAAEtYLIBXsVotWn8wDbLS0eyvk4VDJxtCoc

Also see #155

@buildreactive

Copy link
Copy Markdown

+1
This would be REALLY GOOD to do soon as it blocks updating hackney that now have flagged vulnerabilities in sobelow:

Also see #155

@justinbkay

Copy link
Copy Markdown

@lau Can we get this moving? It is killing my deploy flow.

@gilbertwong96

Copy link
Copy Markdown

@lau Can we get this moving? It is killing my deploy flow.

You can fork it first😂

@lau
lau merged commit 766f38d into lau:master Jul 14, 2026
0 of 2 checks passed
midigofrank added a commit to OpenFn/lightning that referenced this pull request Jul 28, 2026
hackney 4.x carries the fixes for the four advisories .mix_audit.ignore was
suppressing, so both ignore lists shrink to what is genuinely unfixable.

- hackney 4.4.5 -> 4.6.0, which fixes a hackney_conn process leak on
  connections flagged no_reuse. 4.6.0 is the ceiling: 4.6.1 and later require
  h2 ~> 0.11.0 while hackney's own webtransport dep requires h2 ~> 0.10.4.
- swoosh -> 1.26.3, fixing CVE-2026-54893. This needs tidewave 0.8, because
  swoosh 1.18.3 and later require req ~> 0.5.10, and every req that new
  requires mime ~> 2.0, which google_gax pins away from. tidewave 0.8 drops
  req altogether, so req leaves the tree and takes CVE-2026-49755 with it.
- tzdata tracks upstream master for `hackney ~> 1.17 or ~> 4.0`
  (lau/tzdata#170), which is not on Hex yet.
- Drop metrics and unicode_util_compat from the lock; hackney 4 depends on
  neither.

.mix_audit.ignore is now empty and hex_audit/0 is down to the two cowlib
advisories with no patched release. The file stays because CI passes it via
--ignore-file and mix_audit reads it with File.read!/1.

Filter the httpoison 3 callback contract warnings: hackney 4 made a client
handle a pid where it was a reference, but HTTPoison.AsyncResponse.t() still
declares id: reference().
stuartc added a commit to OpenFn/lightning that referenced this pull request Jul 29, 2026
* First pass at updating and overriding

* Tests passing

* Update Sentry config for new version

* Mitigate typespec issues in httpoison

* DIsable tzupdates for now

* Take hackney 4.6 and clear the resolved advisories

hackney 4.x carries the fixes for the four advisories .mix_audit.ignore was
suppressing, so both ignore lists shrink to what is genuinely unfixable.

- hackney 4.4.5 -> 4.6.0, which fixes a hackney_conn process leak on
  connections flagged no_reuse. 4.6.0 is the ceiling: 4.6.1 and later require
  h2 ~> 0.11.0 while hackney's own webtransport dep requires h2 ~> 0.10.4.
- swoosh -> 1.26.3, fixing CVE-2026-54893. This needs tidewave 0.8, because
  swoosh 1.18.3 and later require req ~> 0.5.10, and every req that new
  requires mime ~> 2.0, which google_gax pins away from. tidewave 0.8 drops
  req altogether, so req leaves the tree and takes CVE-2026-49755 with it.
- tzdata tracks upstream master for `hackney ~> 1.17 or ~> 4.0`
  (lau/tzdata#170), which is not on Hex yet.
- Drop metrics and unicode_util_compat from the lock; hackney 4 depends on
  neither.

.mix_audit.ignore is now empty and hex_audit/0 is down to the two cowlib
advisories with no patched release. The file stays because CI passes it via
--ignore-file and mix_audit reads it with File.read!/1.

Filter the httpoison 3 callback contract warnings: hackney 4 made a client
handle a pid where it was a reference, but HTTPoison.AsyncResponse.t() still
declares id: reference().

* Pin hackney to HTTP/1.1 and keep tzdata updates out of tests

hackney 4 negotiates HTTP/2 by default where 1.x was HTTP/1.1 only. Concurrent
requests to one host multiplex onto a single connection, so retiring that
connection fails every in-flight request at once. mix lightning.install_schemas
lost about a quarter of its fetches to :closed this way. They were retried, but
a transport change is not something this upgrade needs.

tzdata's autoupdater works again now that it accepts hackney 4, so drop the
config that disabled it. Disable it in test instead: it polls IANA a few
seconds after boot, and CI starts from a fresh container every run.

* Retry hackney's mislabelled stale-pool error in install_schemas

hackney keeps a closing pooled connection alive briefly so requests that raced
the checkout get an answer instead of crashing the caller. It means to answer
{:closed, _} -- the comment in hackney_conn.erl says as much -- but the
catch-all it falls through to answers :invalid_state, which was not in
@retriable_reasons. A package hitting that race was skipped after one attempt.

* Note the upstream fix for the httpoison dialyzer filters

edgurgel/httpoison#511 already retypes the async struct ids as `id: pid` and
drops the dead `stream_next/1` clause, so these three filters are temporary.
It merged on 2026-07-05 and 3.0.0 shipped on 2026-06-14, so there is nothing
to do but wait for the next release. Record that so the filters get removed
then rather than outliving the bug.

* Bump cowboy/cowlib, declare finch, pin the tzdata ref

cowboy 2.18.0 and cowlib 2.19.0 clear EEF-CVE-2026-65624 and EEF-CVE-2026-59248.
Both were published on 2026-07-28, about an hour after this branch's last lint
run, so hex.audit was green then and would fail now. Back to exit 0 with only
the two cowlib records that carry no fixed event.

finch backs the app's own Lightning.Finch pool and the default Tesla adapter,
but its version was resolving entirely through prom_ex and goth. Dropping or
loosening either would break the supervision tree with no compile-time signal.
Sentry 13 defaulting its client to Finch makes it worth stating outright.

tzdata takes an explicit ref. The lock pinned the commit, but `github:` with no
ref tracks the default branch, so unlocking it would pull whatever master
happens to be at that moment into a release. Also drop the guess that the fix
lands in 1.1.5: master still declares 1.1.4 and no release is scheduled.

---------

Co-authored-by: Frank Midigo <midigofrank@gmail.com>
Co-authored-by: Stuart Corbishley <corbish@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please upgrade your hackney dependency when possible